package com.example.mapper;

import com.example.entity.user.Farmer;
import com.example.entity.item.Items;
import com.example.entity.user.Room;
import com.example.entity.dto.FarmerDTO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface FarmerMapper {

    @Delete("delete from farmer where id=#{id}")
    int deleteFarmerById(Integer id);

    int updateFarmerById(Farmer farmer);

    @Select("select * from farmer where id = #{id}")
    Farmer selectFarmerById(Integer id);

    @Select("select * from room where roomId=#{roomId}")
    Room selectRoomById(String roomId);

    List<Farmer> selectFarmerAll(Farmer farmer);

    @Select("select * from farmer where username = #{username}")
    Farmer selectFarmerByUsername(String username);

    @Select("select * from farmer where username = #{username}")
    FarmerDTO selectFarmerByUsernameDTO(String username);

    @Select("select * from items where itemOwner=#{itemOwner}")
    List<Items> selectItemByItemOwner(String itemOwner);

    @Select("select * from itemList where itemId like concat(#{category},'%') order by itemId desc limit 1")
    String selectNewItemId(String category);

    @Insert("insert into items(itemId,itemName,itemPrice,itemStock,itemDesc) values (#{itemId},#{itemName},#{itemPrice},#{itemStock},#{itemDesc})")
    void JoinItem(String itemId,String itemName,double itemPrice,int itemStock,String itemDesc);

    @Insert("insert into itemList(itemId,itemName,itemCategory,itemType,itemClass) values (#{itemId},#{itemName},#{itemCategory},#{itemType},#{itemClass})")
    void JoinItemList(String itemId,String itemName,String itemCategory,String itemType,String itemClass);

}
